home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q1082.dms / q1082.adf / src.lzh / Fig / blink.c < prev    next >
C/C++ Source or Header  |  1991-07-18  |  2KB  |  101 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    Febuary 1988.
  6.  *
  7.  *    %W%    %G%
  8. */
  9. #include "fig.h"
  10.  
  11. static int        cursor_on, cursor_is_moving;
  12. static int        cursor_x, cursor_y;
  13. static int        blink();
  14. int        (*erase)()=0;
  15. int        (*draw)()=0;
  16. static struct itimerval    blink_timer;
  17.  
  18. turn_on_blinking_cursor(draw_cursor, erase_cursor, x, y, sec, usec)
  19. int    (*draw_cursor)();
  20. int    (*erase_cursor)();
  21. int    x, y;
  22. long    sec, usec;
  23. {
  24.     draw = draw_cursor;
  25.     erase = erase_cursor;
  26.     cursor_is_moving = 0;
  27.     cursor_x = x;
  28.     cursor_y = y;
  29. #ifndef AMIGA
  30.     blink_timer.it_interval.tv_usec = usec;
  31.     blink_timer.it_interval.tv_sec = sec;
  32.     blink_timer.it_value.tv_usec = usec;
  33.     blink_timer.it_value.tv_sec = sec;
  34. #endif AMIGA
  35.     draw(x, y);
  36.     cursor_on = 1;
  37. #ifndef AMIGA
  38. #define SIGALRM 0
  39. #define ITIMER_REAL 1
  40.     signal(SIGALRM, blink);
  41.     setitimer(ITIMER_REAL, &blink_timer, (struct itimerval *)0);
  42.     /*
  43.     (void) notify_set_itimer_func(&me, blink, ITIMER_REAL, &blink_timer, 0);
  44.     */
  45. #endif AMIGA
  46.     }
  47.  
  48. turn_off_blinking_cursor()
  49. {
  50.     if (!draw) return;
  51.     if (cursor_on) erase(cursor_x, cursor_y);
  52.     draw = erase = NULL;
  53. #ifndef AMIGA
  54.     blink_timer.it_interval.tv_usec = 0;
  55.     blink_timer.it_interval.tv_sec = 0;
  56.     blink_timer.it_value.tv_usec = 0;
  57.     blink_timer.it_value.tv_sec = 0;
  58.     setitimer(ITIMER_REAL, &blink_timer, (struct itimerval *)0);
  59.     /*
  60.     (void) notify_set_itimer_func(&me, blink, ITIMER_REAL, 0, 0);
  61.     */
  62. #endif AMIGA
  63.     }
  64.  
  65. static
  66. blink()
  67. {
  68.     if (cursor_is_moving) return(0);
  69.     if (cursor_on) {
  70.         erase(cursor_x, cursor_y);
  71.         cursor_on = 0;
  72.         }
  73.     else {
  74.         draw(cursor_x, cursor_y);
  75.         cursor_on = 1;
  76.         }
  77.     return(0);
  78.     }
  79.  
  80.  
  81. timerfunc()
  82. {
  83.  static int count=5;
  84.  if (--count>0) return;
  85.  count=5;
  86.  if (!draw) return 0;
  87.  blink();
  88. }
  89.  
  90. move_blinking_cursor(x, y)
  91. int    x, y;
  92. {
  93.     cursor_is_moving = 1;
  94.     if (cursor_on) erase(cursor_x, cursor_y);
  95.     cursor_x = x;
  96.     cursor_y = y;
  97.     draw(cursor_x, cursor_y);
  98.     cursor_on = 1;
  99.     cursor_is_moving = 0;
  100.     }
  101.